The purpose of this document is to serve as motivating example (i.e. R, Markdown, and Open data are cool!), but will also serve to structure the rest of this workshop in that we will see how to work with and visualize data in R and combine code and documentation with R Markdown. Additionally, the tools we will be using come from The Tidyverse which is an opinionated (but effective) way to think about organizing and analyzing data in R.
Since the Narragansett Bay Commission has data availble directly from the web (very cool!), we will use that as our example. Even better, the way to table builder is structured it essentially works as an API (Application Programming Interface) and we can build our queries by hand and hit the service directly from R.
date_url <- paste0(params$year1,"/01/01 12:00 AM-",params$year2,"/12/31 11:59 PM")
date_url_enc <- RCurl::curlEscape(date_url)
url <- paste0("http://snapshot.narrabay.com/app/Data/ExportCsv?page=1&p=Chl,pH,Temp,Z&t=",
date_url_enc,
"&l=5,9,6,7,8,1,2,3,4")
narrabay_data<-read_csv(url)
## Parsed with column specification:
## cols(
## Location = col_character(),
## Time = col_character(),
## Chl = col_double(),
## pH = col_double(),
## Temp = col_double(),
## Z = col_double()
## )
Let’s tidy up this dataset.
datatable(narrabay_data)
## Warning in instance$preRenderHook(instance): It seems your data is too
## big for client-side DataTables. You may consider server-side processing:
## https://rstudio.github.io/DT/server.html